<?php
/**
 * 模拟head命令
 * php head.php a.txt
 * type a.txt | php head.php
 * User: Administrator
 * Time: 2015/11/2 14:47
 */

$lines = array();

if ($argc == 1) {
	while (!feof(STDIN)) {
		$lines = fread(STDIN, 10);
		echo $lines;
	}
	exit;
}

if ($argc == 2) {
	$lines = file($argv[1]);
}

foreach ($lines as $line) {
	echo $line . PHP_EOL;
}


